1
general::
Phrase(s): pull something out of a hat [and] pull something out of thin air
1. Lit. [for a magician] to make something, such as a live rabbit, seem to appear by pulling it out of a top hat or out of the air. • He pulled a rabbit out of a hat and then pulled a chicken out of thin air. 2. Fig. to produce something seemingly out of nowhere. • Where am I going to get the money? I can’t just pull it out of a hat! • I don’t know where she found the book. She pulled it out of thin air, I guess.
McGrawhill's American Idioms And Phrasal Verbs
2
general::
Produce suddenly and surprisingly, as if by magic. For example, We can't just pull the answers out of a hat. This expression alludes to the magician's trick of pulling some unexpected object out of a hat. That object is often a rabbit, and the expression pull a rabbit out of a hat is often used to mean "get magical results," as in Much as I would like to be able to pull a rabbit out of a hat, I doubt if I can find further funding for this project.
American Heritage Idioms